#pragma once

#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

namespace Local_Inetaddr
{
    class Inetaddr
    {
    public:
        Inetaddr(struct sockaddr_in &addr)
            : _addr(addr)
        {
            _ip = inet_ntoa(_addr.sin_addr);
            _port = ntohs(_addr.sin_port);
        }

        std::string GetIp()
        {
            return _ip;
        }

        uint16_t GetPort()
        {
            return _port;
        }

        std::string GetStrAddr()
        {
            return _ip + " : " + std::to_string(_port);
        }

        const struct sockaddr_in &GetAddr()
        {
            return _addr;
        }

        bool operator==(const Inetaddr &input)
        {
            return (input._ip == _ip && input._port == _port);
        }

         bool operator!=(const Inetaddr &input)
        {
            return !this->operator==(input);
        }
    private:
        struct sockaddr_in _addr;
        std::string _ip;
        uint16_t _port;
    };
}